<?php

namespace yuankezhan\yiiTableWidget;

class TableSelectAttribute
{
    /**
     * @var string $selectCallback checkbox选中&取消后的js回调 返回一个全部选中的checkbox的value值数组 和 当前点击元素
     */
    public string $selectCallback = "";

    /**
     * @var string $dataKey 选择框里的value值对应的data数据里的key
     */
    public string $dataKey;

    public string $checkBoxName = "";

    public string $checkBoxClass = "";

    /**
     * @var ?method $rowCantSelectFun 行是否能选择的判断PHP匿名函数 function($item, $index) use ($data) { return SelectFuncReturn 类;}  $item 当前行的数据，  $index 当前行索引
     * @return SelectFuncReturn
     */
    public $rowCantSelectFun = null;

    public static function set($dataKey, $selectCallback = "", $rowCantSelectFun = null, $checkBoxName = "", $checkBoxClass = "")
    {
        $obj = new self();
        $obj->dataKey = $dataKey;
        $obj->selectCallback = $selectCallback;
        $obj->rowCantSelectFun = $rowCantSelectFun;
        $obj->checkBoxName = $checkBoxName;
        $obj->checkBoxClass = $checkBoxClass;
        return $obj;
    }
}